	<?php $this->load->view('common/head')?>
	
	<!-- Begin of Sidebar -->
	<?php $this->load->view('common/sidebar')?>
	
	<?php /*********************************/ ?>
	
	
	<?php /****************************/ ?>
	<style>
		.f {display:none}
		.new-inputs {width:200px;display:none}
		.highlight { background-color: yellow }
	</style>

    
	<?php /****************************/ ?>
	<script defer src="<?php echo $this->config->item('js')?>/jquery.highlight-4.closure.js"></script> <!-- highlight -->
	
	<!-- Modal Box Content -->
	<div id="dialog" title="About" style="display: none;">
		<p class='p1'></p>
		
		<p class='p2'>
			<select id="q" name="q" multiple="multiple">
				<option value="company" >	Company Name</option>
				<option value="contact" >	Contact Name</option>
				<option value="history" >	History</option>
				<option value="flag" >		Flag</option>
				<option value="rate" >		Rate</option>
				<option value="pevent" >		Event</option>
				<option value="title" >		Title</option>
				<option value="gender" >	Gender</option>
				<option value="email" >		Email</option>
				<option value="mobile" >	Mobile/Phone/Fax</option>
				<!--option value="address" >	Address</option-->
				<option value="country" >	Country</option>
				<option value="city" >		City</option>
				<option value="lang" >		Lang</option>
				<option value="website" >	Website</option>
				<option value="job-title">	Job Title</option>
				<!--option value="notes" >		Notes</option-->
			</select></p>
	</div> 
	<!--! end of #info-dialog -->
	
    <!-- Begin of #main -->
    <div id="main" role="main">
    	
    	<!-- Begin of titlebar/breadcrumbs -->
		<div id="title-bar">
			<ul id="breadcrumbs">
				<li><a href="<?php echo site_url()?>" title="Home"><span id="bc-home"></span></a></li>
				<li><a href="search" title="Search">Search</a></li>
				<li class="no-hover">Main</li>
			</ul>
		</div> <!--! end of #title-bar -->
		
		<div class="shadow-bottom shadow-titlebar"></div>
		
		<!-- Begin of #main-content -->
		<div id="main-content">
			<div class="container_12">
			
			<!-- Put your content here! -->
			<div class="grid_12">
				<div class="block-border">
					<div class="block-header"><h1>Search</h1></div>
					<div class="block-content"></div>
				</div>
			</div>
			
			<!--  -->
		<div class="grid_8">
				<div class="block-border">
					<div class="block-header">
						<h1 style="cursor:cell;" id="for_title" onClick="options()">Click Me (Search Criteria)</h1><span></span>
					</div>
					<div class="block-content ">
					<br>
					<div>
					<form id="form" class="block-content form" action="" method="post">
						
						<!-- contact -->
						<div id="contact_c">
							<!-- contact name -->
							<div class="_50">
								<p class="medium-label">
								<label for="contact_c"> Contact Name </label>
								<select id="allcontact" name="allcontact[]" multiple="multiple">
								<?php foreach($con_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->name_ar?> - <?php echo $row->name_en?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
							<div class="_50">
								<p class="medium-label">
								<label for="contact_c"> Part of the Name </label>
								<input type='text' id='contact_part' name='contact_part' />
								</p>
							</div>
							
							<!-- company -->
							<div class="_50">
								<p class="medium-label">
								<label for="company_c"> Company Name </label>

								<select id="allcompany" name="allcompany[]" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->name?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>							
							<div class="_50">
								<p class="medium-label">
								<label for="contact_c"> Part of the Name </label>
								<input type='text' id='company_part' name='company_part' />
								</p>
							</div>
							
							<!-- Mobile/Phone/fax.. -->
							<div class="_50">
								<p class="medium-label">
								<label for="num"> Mobile/Phone/Fax </label>

								<select id="num" name="num[]" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<option value="com_<?php echo $row->id?>">
									<?php if($row->phone1 !=''):?>
										<?php echo $row->phone1.' - '?>
									<?php endif;?>
									
									<?php if($row->phone2 !=''):?>
										<?php echo $row->phone2.' - '?>
									<?php endif;?>
									
									<?php if($row->phone3 !=''):?>
										<?php echo $row->phone3.' - '?>
									<?php endif;?>
									
									<?php if($row->fax1 !=''):?>
										<?php echo $row->fax1.' - '?>
									<?php endif;?>
									
									<?php if($row->fax2 !=''):?>
										<?php echo $row->fax2.' '?>
									<?php endif;?>
									</option>
								<?php endforeach;?>
								
								<?php foreach($con_list as $row):?>
									<option value="con_<?php echo $row->id?>">
									<?php if($row->mobile1 !=''):?>
									<?php echo $row->mobile1.' '?>
									<?php endif;?>
									
									<?php if($row->mobile2 !=''):?>
									<?php echo $row->mobile2.' '?>
									<?php endif;?>
									
									<?php if($row->home_phone !=''):?>
									<?php echo $row->home_phone.' '?>
									<?php endif;?>
									
									<?php if($row->fax !=''):?>
									<?php echo $row->fax?>
									<?php endif;?>
								<?php endforeach;?>
								</option>
								</select>
								</p>
							</div>							
							<div class="_50">
								<p class="medium-label">
								<label for="number_part"> Part of the Number </label>
								<input type='text' id='number_part' name='number_part' />
								</p>
							</div>
							
							
							<!-- rate -->
							<div class="_100">
								<p class="medium-label">
									<label for="rate"> Rate </label>
									<select class="c" id="rate-c" name="rate_op" multiple="multiple">
										<option value="eq"> 	Equal ( = ) </option>
										<option value="not-eq"> 	NOT Equal ( ≠ ) </option>
										<option value="more"> 	More Than ( &gt; ) </option>
										<option value="more-eq"> 	More or Equal ( &gt;= ) </option>
										<option value="less"> 	Less than ( &lt; )</option>
										<option value="less-eq"> 	Less or Equal ( &lt;= )</option>
									</select>
									<select class="" id="rate" name="rate[]" multiple="multiple">
										<?php $i=0;while($i < 5){echo "<option id='$i'>$i</option>";$i+=0.5;}?>
									</select>
								</p>
							</div>
								
							<!-- Job Title -->
							<div class="_50">
								<p class="medium-label">
								<label for="job_des"> Job Title </label>

								<select id="job_des" name="job_des[]" multiple="multiple">
								<?php foreach($con_list as $row):?>
									<?php if($row->job_des!=''):?><option value="<?php echo $row->id?>"><?php echo $row->job_des?></option><?php endif;?>
								<?php endforeach;?>
								</select>
								</p>
							</div>							
							<div class="_50">
								<p class="medium-label">
								<label for="contact_c"> Part of the Job Title </label>
								<input type='text' id='jobdes_part' name='jobdes_part' />
								</p>
							</div>
							
							<!-- Flag -->
							<div class="_75">
								<p class="medium-label">
								<label for="flag"> Flag </label>
								<select id="flag" name="flag[]" multiple="multiple">
								<?php foreach($flag_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->name_en?> - <?php echo $row->name_ar?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
							
							
							<!-- Title -->
							<div class="_75">
								<p class="medium-label">
								<label for="title"> Title </label>
								<select class="" id="title" name="title[]" multiple="multiple">
								<?php foreach($title_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->en_name?> - <?php echo $row->name?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						
							<!-- Gender -->
							<div class="_50">
							<p class="medium-label">
								<span class="label" style="display:inline">Gender</span>
								<label style="display:inline"><input type="checkbox" value="m" name="gender[]" style="opacity: 0;"> M</label>
								<label style="display:inline"><input type="checkbox" value="f" name="gender[]" style="opacity: 0;"> F</label>
							</p>
							</div>
						
							<!-- Lang -->
							<div class="_50">
							<p class="medium-label">
								<span class="label" style="display:inline">Lang</span>
								<label style="display:inline"><input value="ar" type="checkbox" value="ar" name="lang[]" style="opacity: 0;"> Arabic</label>
								<label style="display:inline"><input value="en"  type="checkbox"value="en" name="lang[]" style="opacity: 0;"> English/Other</label>
							</p>
							</div>
						
							<!-- Country -->
							<div class="_50">
							<p class="medium-label">
							<label for="country"> Select Country </label>
							<select name="country[]" id="country" class=""  multiple="multiple">
								<?php foreach($this->config->item('en_countries') as $key=>$value):?>
									<option value="<?php echo $key?>"><?php echo $value?></option>
								<?php endforeach;?>
							</select>							
							</p>
							</div>
						
						<!-- City -->
							<div class="_50">
							<p class="medium-label">
							<label for="name"> City </label>
							<input id="city" name="city" class="" type="text" value="" />				
							</p>
							</div>
						
						<!-- Website -->
							<div class="_50">
							<p class="medium-label">
							<label for="website"> Website </label>
							<select class="" id="website" name="website[]" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<?php if($row->website!=''):?>
									<option value="com_<?php echo $row->id?>"><?php echo $row->website?></option>
									<?php endif;?>
								<?php endforeach;?>
								<?php foreach($con_list as $row):?>
									<?php if($row->website!=''):?>
									<option value="con_<?php echo $row->id?>"><?php echo $row->website?></option>
									<?php endif;?>
								<?php endforeach;?>
								</select>			
							</p>
							</div>
							<div class="_50">
								<p class="medium-label">
								<label for="contact_c"> Part of the Website </label>
								<input type='text' id='website_part' name='website_part' />
								</p>
							</div>
						
						<!-- P event -->
							<div class="_50">
							<p class="medium-label">
							<label for="previous_event"> Previous Event </label>
							<select class="" id="previous_event" name="previous_event[]" multiple="multiple">
								<?php foreach($pevent_list as $row):?>
									<?php if($row->event_name!=''):?><option value="<?php echo $row->id?>"><?php echo $row->event_name?></option><?php endif;?>
								<?php endforeach;?>
							</select>			
							</p>
							</div>
							<div class="_50">
								<p class="medium-label">
								<label for="contact_c"> Part of the Previous Event </label>
								<input type='text' id='pevent_part' name='pevent_part' />
								</p>
							</div>
							
							<div class="_100">
								<p class="medium-label">
								<label for="contact_c"> Search in History Records </label>
								<input type='text' id='history' name='history' />
								</p>
							</div>
							
							<div class="_100">
								<p class="medium-label">
								<label for="contact_c"> Search in Notes </label>
								<input type='text' id='notes' name='notes' />
								</p>
							</div>
						
							
						</div>
						
						<?php /*
						<!-- Contact -->
						<div id="contact_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="contact_c"> Contact Name </label>
								<select id="allcontact" name="allcontact" multiple="multiple">
								<?php foreach($con_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->name_ar?> - <?php echo $row->name_en?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>						
						<!-- Company -->
						<div id="company_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="company_c"> Company Name </label>

								<select id="allcompany" name="allcompany[]" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->name?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>
						<!-- Mobile/Phone/fax.. -->
						<div id="mobile_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="num_c"> Mobile/Phone/Fax </label>

								<select id="num" name="num" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<?php if($row->phone1 !=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->phone1?></option><?php endif;?>
									<?php if($row->phone2 !=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->phone2?></option><?php endif;?>
									<?php if($row->phone3 !=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->phone3?></option><?php endif;?>
									<?php if($row->fax1 !=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->fax1?></option><?php endif;?>
									<?php if($row->fax2 !=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->fax2?></option><?php endif;?>
								<?php endforeach;?>
								<?php foreach($con_list as $row):?>
									<?php if($row->mobile1 !=''):?><option value="con_<?php echo $row->id?>"><?php echo $row->mobile1?></option><?php endif;?>
									<?php if($row->mobile2 !=''):?><option value="con_<?php echo $row->id?>"><?php echo $row->mobile2?></option><?php endif;?>
									<?php if($row->home_phone !=''):?><option value="con_<?php echo $row->id?>"><?php echo $row->home_phone?></option><?php endif;?>
									<?php if($row->fax !=''):?><option value="con_<?php echo $row->id?>"><?php echo $row->fax?></option><?php endif;?>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>
						<!-- Job Title -->
						<div id="job-title_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="job_des"> Job Title </label>

								<select id="job_des" name="job_des" multiple="multiple">
								<?php foreach($con_list as $row):?>
									<?php if($row->job_des!=''):?><option value="<?php echo $row->id?>"><?php echo $row->job_des?></option><?php endif;?>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>
						<!-- Email -->
						<div id="email_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="allemail"> Email </label>

								<select class="" id="allemail" name="allemail" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<?php if($row->email!=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->email?></option><?php endif;?>
								<?php endforeach;?>
								<?php foreach($con_list as $row):?>
									<?php if($row->email!=''):?><option value="con_<?php echo $row->id?>"><?php echo $row->email?></option><?php endif;?>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>
						<!-- Flag -->
						<div id="flag_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="flag"> Flag </label>
								<select id="flag" name="flag" multiple="multiple">
								<?php foreach($flag_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->name_en?> - <?php echo $row->name_ar?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>
						<!-- history -->
						<div id="history_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
								<label for="history"> History </label>
								<input id="history" name="history" class="new-inputs" style="display:inline" type="text" value="" />
								</p>
							</div>
						</div>
						<!-- rate -->
						<div id="rate_c" class="f">
							<div class="_75">
								<p class="inline-medium-label">
									<label for="rate"> Rate </label>
									<select class="c" id="rate-c" name="rate" multiple="multiple">
										<option value="eq"> 	Equal ( = ) </option>
										<option value="not-eq"> 	NOT Equal ( ≠ ) </option>
										<option value="more"> 	More Than ( &gt; ) </option>
										<option value="more-eq"> 	More or Equal ( &gt;= ) </option>
										<option value="less"> 	Less than ( &lt; )</option>
										<option value="less-eq"> 	Less or Equal ( &lt;= )</option>
									</select>
									<select class="" id="rate" name="rate" multiple="multiple">
										<?php $i=0;while($i < 5){echo "<option id='$i'>$i</option>";$i+=0.5;}?>
									</select>
								</p>
							</div>
						</div>
							
						<!-- Title -->
						<div id="title_c" class="f">
							<div class="_50">
								<p class="inline-medium-label">
								<label for="title"> Title </label>
								<select class="" id="title" name="title" multiple="multiple">
								<?php foreach($title_list as $row):?>
									<option value="<?php echo $row->id?>"><?php echo $row->en_name?> - <?php echo $row->name?></option>
								<?php endforeach;?>
								</select>
								</p>
							</div>
						</div>
						<!-- Gender -->
						<div id="gender_c" class="f">
							<div class="_75">
							<p>
								<span class="label" style="display:inline">Gender</span>
								<label style="display:inline"><input type="checkbox" name="checkbox" style="opacity: 0;"> M</label>
								<label style="display:inline"><input type="checkbox" style="opacity: 0;"> F</label>
							</p>
							</div>
						</div>
						<!-- Lang -->
						<div id="lang_c" class="f">
							<div class="_75">
							<p>
								<span class="label" style="display:inline">Lang</span>
								<label style="display:inline"><input value="ar" type="checkbox" name="checkbox" style="opacity: 0;"> Arabic</label>
								<label style="display:inline"><input value="en"  type="checkbox" name="checkbox" style="opacity: 0;"> English/Other</label>
							</p>
							</div>
						</div>
						<!-- Country -->
						<div id="country_c" class="f">
							<div class="_75">
							<p class="inline-medium-label">
							<label for="country"> Select Country </label>
							<select name="country" id="country" class="required"  multiple="multiple">
								<?php foreach($this->config->item('en_countries') as $key=>$value):?>
									<option value="<?php echo $key?>"><?php echo $value?></option>
								<?php endforeach;?>
							</select>							
							</p>
							</div>
						</div>
						
						<!-- City -->
						<div id="city_c" class="f">
							<div class="_50">
							<p class="inline-medium-label">
							<label for="name"> City </label>
							<input id="city" name="name" class="" type="text" value="" />				
							</p>
							</div>
						</div>
						
						
						<!-- Website -->
						<div id="website_c" class="f">
							<div class="_75">
							<p class="inline-medium-label">
							<label for="website"> Website </label>
							<select class="" id="website" name="website" multiple="multiple">
								<?php foreach($com_list as $row):?>
									<?php if($row->website!=''):?><option value="com_<?php echo $row->id?>"><?php echo $row->website?></option><?php endif;?>
								<?php endforeach;?>
								<?php foreach($con_list as $row):?>
									<?php if($row->website!=''):?><option value="con_<?php echo $row->id?>"><?php echo $row->website?></option><?php endif;?>
								<?php endforeach;?>
								</select>			
							</p>
							</div>
						</div>
						
						<!-- P event -->
						<div id="pevent_c" class="f">
							<div class="_75">
							<p class="inline-medium-label">
							<label for="previous_event"> Previous Event </label>
							<select class="" id="previous_event_c" name="previous_event_c" multiple="multiple">
								<option>By Name</option>
								<option>By Start Date</option>
								<option>By End Date</option>
								<option>By Seasonal</option>
								<option>By Country</option>
								<option>By city</option>
								<option>By Address</option>
								<option>By Subject</option>
								<option>By Attendance</option>
								<option>By Organisers</option>
								<option>By Responsable</option>
								<option>By Notes</option>
							</select>
							
							<select class="" id="previous_event" name="previous_event" multiple="multiple">
								<?php foreach($pevent_list as $row):?>
									<?php if($row->event_name!=''):?><option value="<?php echo $row->id?>"><?php echo $row->event_name?></option><?php endif;?>
								<?php endforeach;?>

								</select>			
							</p>
							</div>
						</div>
						
						
						*/?>
						
						
					
				
					<div class="clear"></div>
						<div class="block-actions" style="margin-right: -30px; margin-left: -30px;">
							<ul class="actions-left">
								<li><a class="button red" id="reset-validate-form" href="javascript:;" onClick="$('.f').fadeOut(); return false">Reset</a></li>
							</ul>
							<ul class="actions-right">
								<li><a href="javascript:;" onClick="doSearch()" class="button">Search!</a></li>
							</ul>
						</div>
						</form>

					</div>
					</div>
					
				</div>
				
			</div>
			
			<div class="grid_4">
				<div class="block-border">
					<div class="block-header resultH">
						<h1 style="cursor:cell;" id="for_title" onClick="options()"></h1><span></span>
					</div>
					<div class="block-content result">
						
					</div>
				</div>
			</div>
			
			<div class="clear height-fix"></div>

		</div></div> <!--! end of #main-content -->
  </div> <!--! end of #main -->	

<div class="clear height-fix"></div>
		
<link rel="stylesheet" href="<?php echo $this->config->item('css')?>/jquery.multiselect.css"> <!--  -->
<link rel="stylesheet" href="<?php echo $this->config->item('css')?>/jquery.multiselect.filter.css"> <!--  -->


	<script type="text/javascript">
		
		$().ready(function() {
            
            $('#dialog').dialog({
					minWidth: 450,
					position: "top",
					autoOpen: false,
					modal: true, 
					show: "slide", 
					hide: "slide",
					title: "Loading Info..." 
			});
			        
            $.get("<?php echo $this->config->item('js')?>/jquery.multiselect.min.js", function(){
                $.get("<?php echo $this->config->item('js')?>/jquery.multiselect.filter.js", function(){
                   $("select").multiselect({
					   multiple: true,
					   header: "Select an option",
					   noneSelectedText: "Select an Option",
					   selectedList: 1,

					   minWidth: 300,
					   show: "slide",
					   hide: "slide"

					}).multiselectfilter();
			
				$(".c").multiselect({multiple: false}).multiselectfilter("destroy");
				//$("#allcontact,#allcompany,#allemail").multiselect({multiple: false}).multiselectfilter();

				$("button.ui-multiselect").css('width','200px');
				$(".ui-multiselect-menu").css('width','385px');
				
                
                });
            });
            
			$("#q").bind("multiselectclick", function(event, ui){
				/*
				event: the original event object
				ui.value: value of the checkbox
				ui.text: text of the checkbox
				ui.checked: whether or not the input was checked or unchecked (boolean)
				*/
				
				if(ui.checked)
					$("#"+ui.value+"_c").fadeIn()
				else
					$("#"+ui.value+"_c").fadeOut()
				
			});    
            
   
	
		});
		

		function doSearch()
		{							
			$('.resultH').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
			$('html,body').animate({scrollTop: $('#top').offset().top}, 1000 , function () {}); 
			var result = '';		
			$('.result').html('loading...');
			$.post("<?php echo site_url('search/filter')?>", $("#form").serialize(),
				
				function(data){
					data1 = jQuery.parseJSON( data )
					$('.result').html('<br>')
					
					$('#lq').html(data1.lq);
					
					
					$.each(data1.result, function(index,value){
						$('.result').append('['+value.id+'] '+value.name+'<hr>');
						
					});
					
					if(data1.count==0){
						$('.result').html('<br>No Match(s)');
						$('.resultH').html('<h1>No Match(s)</h1>');
					}else{
						$('.resultH').html('<h1>'+data1.count+' Match(s)</h1>');	
					}
						
					if($('#contact_part').val()!='')
						$('.result').highlight($('#contact_part').val());
						
					if($('#company_part').val()!='')
						$('.result').highlight($('#company_part').val());
						
					if($('#number_part').val()!='')
						$('.result').highlight($('#number_part').val());

										
				}

				
			),'json';
			
			
		}
		
		function options()
		{
			$("#dialog").dialog({title:"Search Criteria", autoOpen:true});
			$('#dialog p.p1').html('Select as many filters as you want');
		}
		
    </script>




	
	
	
	<?php /*********************************/ ?>
	<!-- Begin of footer -->
	<?php $this->load->view('common/footer')?>
